home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-27 | 2.7 KB | 119 lines | [TEXT/KAHL] |
- // -----------------------------------------------------------------------------
- // File : demoTab.c
- // Date : November 5, 1994
- // Author : Jim Stout
- // Purpose : some tabPanel demonstrations
- //
- // -----------------------------------------------------------------------------
- #include <GestaltEqu.h>
-
- #include "demoShell.h"
- #include "demoTab.h"
- #include "dialogAssist.h"
- #include "movableModal.h"
- #include "panelAssist.h"
-
- #define TABCNTL 3 // ID for Tab control
- #define CTLTOKEEP 4 // controls that are on all panels
-
- #define FIRSTPANEL 160 // DITL id for "base" panel
-
- #define DEMOTAB1 160 // DLOG id's for each demo
- #define DEMOTAB2 180
- #define DEMOTAB3 190
- #define DEMOTAB4 200
-
- static pascal char tabFilter (DialogPtr theDialog, EventRecord *theEvent,
- short *theItem);
-
- extern void demoTab(short demoNum)
- {
- DialogPtr d;
- ModalFilterUPP filterUPP;
- short currPanel=1,toPanel,itemHit;
- GrafPtr savePort;
-
- if(daGestalt(gestaltDITLExtAttr) == -1L) {
- if(daGestalt(gestaltCTBVersion) < 0x0100) {
- StopAlert(256, nil);
- return;
- }
- }
- switch(demoNum) {
- case iDemoTab1:
- d = GetNewDialog(DEMOTAB1, 0L, (DialogPtr)-1);
- break;
- case iDemoTab2:
- d = GetNewDialog(DEMOTAB2, 0L, (DialogPtr)-1);
- break;
- case iDemoTab3:
- d = GetNewDialog(DEMOTAB3, 0L, (DialogPtr)-1);
- break;
- case iDemoTab4:
- d = GetNewDialog(DEMOTAB4, 0L, (DialogPtr)-1);
- break;
- }
- if(d) {
- GetPort(&savePort);
- SetPort(d);
-
- filterUPP = NewModalFilterProc(tabFilter);
- if(filterUPP == nil)
- return;
-
- toPanel = daGetCtlValue(d, TABCNTL);
-
- panelSwap(d, FIRSTPANEL, currPanel, toPanel, CTLTOKEEP);
-
- currPanel = toPanel;
-
- ShowWindow(d);
-
- do {
- movableModalDialog(filterUPP,&itemHit);
-
- if(itemHit == TABCNTL) {
- toPanel = daGetCtlValue(d, TABCNTL);
- if(toPanel != currPanel) {
- panelSwap(d, FIRSTPANEL, currPanel, toPanel, CTLTOKEEP);
- currPanel = toPanel;
- }
-
- }
- }while(itemHit != ok && itemHit != cancel);
- DisposDialog(d);
- DisposeRoutineDescriptor(filterUPP);
- SetPort(savePort);
- }
- }
-
- static pascal char tabFilter (DialogPtr theDialog, EventRecord *theEvent,
- short *theItem)
- {
- char c, result = FALSE;
-
- switch(theEvent->what) {
- case keyDown:
- case autoKey:
-
- c = theEvent->message & charCodeMask;
-
- // check for an exit key, really should put this into movableModal…
-
- result = daExitKey(theDialog, theEvent, theItem, cancel);
- if(result)
- break;
-
- // check for cmd or cntl TAB to switch panels
-
- if(theEvent->modifiers & controlKey ||
- theEvent->modifiers & cmdKey) {
- result = panelCmdTab(theDialog, TABCNTL, c, theItem);
- if(result)
- break;
- }
- break;
- }
- return(result);
- }
-